package com.shumei.servlet.productservlet;


import com.shumei.DAO.ProductDAO;
import com.shumei.DAO.impl.ProductDAOImpl;
import com.shumei.pojo.Product;
import com.shumei.servlet.ViewBaseServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/mproductindex")
public class MProductIndexServlet extends ViewBaseServlet {
    private ProductDAO productDAO = new ProductDAOImpl();
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        doGet(req, resp);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        List<Product> productlist= productDAO.getProductList();
        request.setAttribute("products",productlist);
        super.processTemplate("admin/index", request, response);
    }
}
